articles

home / developersection / articles / string builder in c sharp .net

String Builder in C sharp .NET

Anonymous User 11915 29-Jul-2010

StringBuilder is a dynamic string array, in which we can append any number of strings.

Example
         StringBuilder sb = new StringBuilder();
//creating new string builder onject.
        private void button1_Click(object sender, EventArgs e)
        {
         sb.Append(textBox1.Text);
//adding value to string builder
            textBox1.Text = "";
        } 
        private void button2_Click(object sender, EventArgs e)
        {
MessageBox.Show("Capacity: " + sb.Capacity.ToString() + "\nValue: " + sb.ToString() + "\nLength: " + sb.Length.ToString());     
//displaying capacity, length and value of stringbuilder    
     }

 

Screen shot

String Builder in C sharp .NET String Builder in C sharp .NET



Updated 04-Mar-2020

I am a content writter !


Message

Leave Comment

2 Comments

Comments

Liked By